import { sortByDate } from '@renderer/utils'
import { defineStore } from 'pinia'

const habitStore = defineStore('habit', {
  state: (): HabitState => ({
    habitList: [],
    currentHabit: undefined
  }),
  actions: {
    async getHabitList() {
      this.habitList = []
      this.habitList = await window.api.getHabitDataList()
      sortByDate(this.habitList)
      return this.habitList
    }
  }
})

export default habitStore
